target: base sqlite sqlitepool mysqlpool

include ../../makeconf

OBJ_PATH 					= .
LIB_OUTPUT_BASE 			= $(LIB_OUTPUT_PATH)/libdbx.base$(LIB_EXTNAME)

LIB_OUTPUT_MYSQL			= $(LIB_OUTPUT_PATH)/libdbx.mysql$(LIB_EXTNAME)
LIB_OUTPUT_SQLITE			= $(LIB_OUTPUT_PATH)/libdbx.sqlite$(LIB_EXTNAME)
LIB_OUTPUT_POSTGRESQL		= $(LIB_OUTPUT_PATH)/libdbx.postgresql$(LIB_EXTNAME)

DLL_OUTPUT_MYSQLPOOL		= $(DLL_OUTPUT_PATH)/libdbx.mysqlpool$(DLL_EXTNAME)
DLL_OUTPUT_SQLITEPOOL		= $(DLL_OUTPUT_PATH)/libdbx.sqlitepool$(DLL_EXTNAME)
DLL_OUTPUT_POSTGRESQLPOOL   = $(DLL_OUTPUT_PATH)/libdbx.postgresqlpool$(DLL_EXTNAME)

MYSQL_INCPATH 				= -I$(LIB_OUTPUT_PATH)/mysql/inc
MYSQL_LIBLINK 				= -L$(LIB_OUTPUT_PATH)/mysql/lib -lmysqlclient -lzlib
POSTGRESQL_INCPATH 			= -I$(LIB_OUTPUT_PATH)/postgresql/inc
POSTGRESQL_LIBLINK 			= -L$(LIB_OUTPUT_PATH)/postgresql/lib -lpq

VPATH 						= ./src:$(OBJ_PATH)

.SUFFIXES:
.SUFFIXES: .cpp .c .o
.c.o:
	$(CPP) $(INCPATH) -c -o $(OBJ_PATH)/$@ $<

.cpp.o:
	$(CPP) $(INCPATH) -c -o $(OBJ_PATH)/$@ $<

MySQLConnect.o: MySQLConnect.cpp
	$(CPP) $(INCPATH) $(MYSQL_INCPATH) -c -o $(OBJ_PATH)/$@ $<

MySQLConnectPool.o: MySQLConnectPool.cpp
	$(CPP) $(INCPATH) $(MYSQL_INCPATH) -c -o $(OBJ_PATH)/$@ $<

PostgreSQLConnect.o: PostgreSQLConnect.cpp
	$(CPP) $(INCPATH) $(POSTGRESQL_INCPATH) -c -o $(OBJ_PATH)/$@ $<

PostgreSQLConnectPool.o: PostgreSQLConnectPool.cpp
	$(CPP) $(INCPATH) $(POSTGRESQL_INCPATH) -c -o $(OBJ_PATH)/$@ $<

base: DBConnectPool.o RedisConnect.o DBConnect.o
	$(ARLIB) $(LIB_OUTPUT_BASE) $(OBJ_PATH)/DBConnectPool.o $(OBJ_PATH)/RedisConnect.o $(OBJ_PATH)/DBConnect.o

sqlite: SQLiteConnect.o
	$(ARLIB) $(LIB_OUTPUT_SQLITE) $(OBJ_PATH)/SQLiteConnect.o

mysqlpool: MySQLConnect.o MySQLConnectPool.o
	$(CPP_DLL) -o $(DLL_OUTPUT_MYSQLPOOL) $(OBJ_PATH)/MySQLConnect.o $(OBJ_PATH)/MySQLConnectPool.o -L$(LIB_OUTPUT_PATH) -ldbx.base $(LIBLINK) $(MYSQL_LIBLINK)

sqlitepool: SQLiteConnect.o SQLiteConnectPool.o
	$(CPP_DLL) -o $(DLL_OUTPUT_SQLITEPOOL) $(OBJ_PATH)/SQLiteConnect.o $(OBJ_PATH)/SQLiteConnectPool.o -L$(LIB_OUTPUT_PATH) -ldbx.base $(LIBLINK) -lsqlite

postgresqlpool: PostgreSQLConnect.o PostgreSQLConnectPool.o
	$(CPP_DLL) -o $(DLL_OUTPUT_POSTGRESQLPOOL) $(OBJ_PATH)/PostgreSQLConnect.o $(OBJ_PATH)/PostgreSQLConnectPool.o -L$(LIB_OUTPUT_PATH) -ldbx.base $(LIBLINK) $(POSTGRESQL_LIBLINK)

clean:
	@$(DELETEFILE) $(OBJ_PATH)/*.o
